package com.toidep.fragment.mains;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.toidep.R;
import com.toidep.activities.MainActivity;
import com.toidep.api.ApiController;
import com.toidep.base.BaseFragment;
import com.toidep.config.Constants;
import com.toidep.interfaces.ResponseListener;

public class IntroductionFragment extends BaseFragment {

	private MainActivity mainActivity;

	private TextView txtContent;
	private View view;

	/**
	 * Set lai cac base value cho fragment: cac item cua thanh header, currentCategory cua menuSideBar
	 */
	public void setBaseValues() {
		ApiController.getIntroduction(getActivity(), new ResponseListener() {
			
			@Override
			public void processResponse(int inintstall) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void processResponse(String response) {
				// TODO Auto-generated method stub
				txtContent.setText(response);
			}
		});
		mainActivity.currentCategory = Constants.CATEGORY_HOME_INTRO;
		mainActivity.mainFragment.setTittle(mainActivity.getString(R.string.label_category_introduction));
		mainActivity.mainFragment.showButtonSlide(true);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		view = inflater.inflate(R.layout.fragment_introduction, container, false);

		txtContent = (TextView) view.findViewById(R.id.txtIntroduction);
		mainActivity = (MainActivity) getActivity();

		setBaseValues();
		
		return view;
	}
	
	private static IntroductionFragment myFragment;
	public static IntroductionFragment newInstance() {
		if (myFragment == null) {
			myFragment = new IntroductionFragment();
			myFragment.setRootFragment(true);
		}
		
		return myFragment;
	}
	
}
